package com.wangsh.userscenter.service.users.pojo;

import java.util.Date;

import com.alibaba.fastjson.JSONObject;
import com.wangsh.userscenter.common.pojo.BasePojo;
import com.wangsh.userscenter.common.util.DateUtil;

/**
 * 管理员的POJO类
 * @author wangsh
 *
 */
public class AAdmins extends BasePojo<AAdmins>
{
	private int id;
	private String email ;
	private String password ; 
	private String trueName ;
	private String qq ; 
	private String phone ; 
	private int loginCount ; 
	private byte status ; 
	private Date createTime;
	private Date updateTime;
	private Date lastLoginTime ; 
	
	/* 字符串描述 */
	private String statusStr ;
	private String ticketStr ; 

	public int getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}
	
	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public String getEmail()
	{
		return email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public String getTrueName()
	{
		return trueName;
	}

	public void setTrueName(String trueName)
	{
		this.trueName = trueName;
	}

	public String getQq()
	{
		return qq;
	}

	public void setQq(String qq)
	{
		this.qq = qq;
	}

	public String getPhone()
	{
		return phone;
	}

	public void setPhone(String phone)
	{
		this.phone = phone;
	}

	public int getLoginCount()
	{
		return loginCount;
	}

	public void setLoginCount(int loginCount)
	{
		this.loginCount = loginCount;
	}

	public Date getLastLoginTime()
	{
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime)
	{
		this.lastLoginTime = lastLoginTime;
	}

	public void setStatusStr(String statusStr)
	{
		this.statusStr = statusStr;
	}
	
	public String getStatusStr()
	{
		// 根据状态值获取字符串描述
		AAdminsEnum[] adminsEnums = AAdminsEnum.values();
		for (int i = 0; i < adminsEnums.length; i++)
		{
			AAdminsEnum adminsEnum = adminsEnums[i];
			if (adminsEnum.toString().startsWith("STATUS_"))
			{
				// 表示是状态的标识
				if (adminsEnum.getStatus() == this.getStatus())
				{
					this.statusStr = adminsEnum.getName();
					break;
				}
			}
		}
		return statusStr;
	}

	@Override
	public JSONObject toJSON()
	{
		DateUtil dateFormatUtil = new DateUtil();
		JSONObject resultJSON = new JSONObject();
		resultJSON.put("id", this.getId() + "");
		resultJSON.put("email", this.getEmail() + "");
		resultJSON.put("trueName", this.getTrueName() + "");
		resultJSON.put("status", this.getStatus() + "");
		resultJSON.put("statusStr", this.getStatusStr() + "");
		resultJSON.put("createTime", dateFormatUtil.formatDateTime(this.getCreateTime()) + "");
		resultJSON.put("updateTime", dateFormatUtil.formatDateTime(this.getUpdateTime()) + "");
		resultJSON.put("lastLoginTime", dateFormatUtil.formatDateTime(this.getLastLoginTime()) + "");
		return resultJSON;
	}

	@Override
	protected AAdmins parseJSON(JSONObject souJSON)
	{
		return null;
	}

	@Override
	public String toString()
	{
		return "AAdmins [id=" + id + ", email=" + email + ", password=" + password + ", trueName=" + trueName + ", qq="
				+ qq + ", phone=" + phone + ", loginCount=" + loginCount + ", status=" + status + ", createtime="
				+ createTime + ", updatetime=" + updateTime + ", lastLoginTime=" + lastLoginTime + ", statusStr="
				+ statusStr + "]";
	}

	public String getTicketStr()
	{
		return ticketStr;
	}

	public void setTicketStr(String ticketStr)
	{
		this.ticketStr = ticketStr;
	}
}